def call(Map params = [:]) {
    // 参数校验
    assert params.version : "version 参数不能为空"
    assert params.serverIp : "serverIp 参数不能为空"
    assert params.sshCredentialsId : "sshCredentialsId 参数不能为空"
    assert params.deployPath : "deployPath 参数不能为空"

    // 初始化工具类
    def artifactUtils = new org.utils.ArtifactUtils()

    // 生成路径和文件名
    def jobName = env.JOB_NAME
    def remoteDir = artifactUtils.buildRemoteDirectory(jobName, params.deployPath, params.version)
    def tarFileName = artifactUtils.generateTarFileName(jobName, params.version, "")
    def remoteFullPath = "${remoteDir}/${tarFileName}"

    // 执行部署操作
    withCredentials([sshUserPrivateKey(
        credentialsId: params.sshCredentialsId,
        usernameVariable: 'SSH_USER',
        keyFileVariable: 'SSH_KEY'
    )]) {
        sh """
            set -e  # 出错立即退出
            ssh -i \${SSH_KEY} \${SSH_USER}@\${serverIp} "mkdir -p ${remoteDir}"
            scp -i \${SSH_KEY} ${tarFileName} \${SSH_USER}@\${serverIp}:${remoteFullPath}
        """
    }
}